﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Web.UI;

public partial class UserControls_OrderShow_New : UCBase
{
    public UserControls_OrderShow_New()
    {
        Name = "生成订单_2";

        swpas = new ShoveWebPartAttribute[18];
        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1004", 759, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("导航文本单元格宽度", "1,1000", 139, "导航文本单元格宽度");
        swpas[2] = new ShoveWebPartAttribute_Int("导航高度", "1,300", 23, "导航高度");
        swpas[3] = new ShoveWebPartAttribute_Int("每页显示个数", "1,20", 5, "每页显示个数");
        swpas[4] = new ShoveWebPartAttribute_Int("底部按钮单元格百分比", "1,100", 50, "底部按钮单元格百分比");
        swpas[5] = new ShoveWebPartAttribute_Text("表格CSS样式", "", "black12", "表格CSS样式");
        swpas[6] = new ShoveWebPartAttribute_Text("文本框样式", "", "in_p2", "文本框样式");
        swpas[7] = new ShoveWebPartAttribute_Text("导航文本样式", "", "Black12", "导航文本样式");
        swpas[8] = new ShoveWebPartAttribute_Text("消费金额样式", "", "red", "消费金额样式");

        swpas[9] = new ShoveWebPartAttribute_Image("导航背景图片1", "", "images/UserControls/bg_gold_23.jpg", "导航背景图片1");
        swpas[10] = new ShoveWebPartAttribute_Image("导航背景图片2", "", "images/UserControls/bg_gold_23_2.jpg", "导航背景图片2");
        swpas[11] = new ShoveWebPartAttribute_Image("删除按钮图片", "", "images/UserControls/b-delete.gif", "删除按钮图片");
        swpas[12] = new ShoveWebPartAttribute_Image("清空购物车图片", "", "images/UserControls/button_car_1.jpg", "清空购物车图片");
        swpas[13] = new ShoveWebPartAttribute_Image("继续购物图片", "", "images/UserControls/button_car_2.jpg", "继续购物图片");
        swpas[14] = new ShoveWebPartAttribute_Image("去收银台图片", "", "images/UserControls/button_car_4.jpg", "去收银台图片");
        swpas[15] = new ShoveWebPartAttribute_Image("表头背景图片", "", "images/UserControls/bg_hui_23_2.jpg", "表头背景图片");

        swpas[16] = new ShoveWebPartAttribute_Color("控件边框颜色", "#cccccc", "控件边框颜色");
        swpas[17] = new ShoveWebPartAttribute_Int("表头高度", "1,100", 23, "表头高度");
    }

    private void InitlayOut()
    {
        tabctr.Width = swpAttributes[0];
        tabctr.BgColor = swpAttributes[16];

        //tdsign.Height = swpAttributes[2];
        //tdsign.Width = swpAttributes[1];
        //tdsign.Attributes.Add("class", swpAttributes[7]);
        //tdsign.Style.Add(HtmlTextWriterStyle.BackgroundImage,"url('"+swpAttributes[9]+"')");
        //tdspace.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url('" + swpAttributes[10] + "')");

        //gvGood.PageSize = Shove._Convert.StrToInt(swpAttributes[3], 5);
        //gvGood.CssClass = swpAttributes[5];
        //gvGood.HeaderStyle.Height = new Unit(swpAttributes[17]);

        //tdtotal.Attributes.Add("class", swpAttributes[8]);
        //tdBottom.Width = swpAttributes[4] + "%";

        //imgdel.Src = "~/" + swpAttributes[12];
        //imggood.Src = "~/" + swpAttributes[13];
        //ibNext.ImageUrl = "~/" + swpAttributes[14];
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            long ID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("SaleID"), 0);
            hID.Value = ID.ToString();

            BindData(ID);
        }
       
        InitlayOut();       
    }

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = true;

        base.OnLoad(e);
    }

    /// <summary>
    /// 加载购物车中的商品
    /// </summary>
    private void BindData(long ID)
    {
        DataTable dt = new DAL.Views.V_Shop_SalesMaster().Open("", "ID=" + ID, "");

        if (dt == null || dt.Rows.Count == 0)
        {
            return;
        }

        DataRow dr = dt.Rows[0];
        lbSalesNo.Text = dr["SalesNo"].ToString();
        lbActualMoney.Text = dr["ActualMoney"].ToString();
        lbPayType.Text = dr["SitePayTypeName"].ToString();
        lbCarriageType.Text = dr["CarriageTypeName"].ToString();        
    }

    protected void gvGood_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Style.Add("background-image", "url('"+swpAttributes[15]+"')");
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {            
            Image img = (Image)e.Row.FindControl("imgGoodPic");
            img.ImageUrl = "~/UpFile/Goods/" + img.ImageUrl;

            TextBox txtNum = (TextBox)e.Row.Cells[8].FindControl("txtNum");
            txtNum.CssClass = swpAttributes[6];
        }
    }

}
